#include <stdio.h>
#include <avr\io.h>
#include <avr\interrupt.h>
//#include <util/twi.h>

#include <string.h>


//#include <compat/ina90.h>


//#define IS_SET(REG, BIT) ((REG & _BV(BIT)) != 0)
//#define SET_BIT(REG, BIT) do {REG |= _BV(BIT);}while(0)
//#define CLR_BIT(REG, BIT) do {REG &= ~_BV(BIT);}while(0)
#define IR_receive PINA
SIGNAL(SIG_OUTPUT_COMPARE1A)
{
//	volatile char k = 0;
	//int switch_value = PORTA;
	if ((PORTA & _BV(1)) != 0)
	PORTA &= ~_BV(1);
	else
	PORTA |= _BV(1);

}

void my_delay ()
{
	volatile char k = 0;
	int i, j;
	for (i = 0; i < 24; i++)
		for (j = 0; j < 160; j++)
				k++;
}

int main()
{
	
	
/*
	OCR1A =1562 ;
	TCCR1A = 0;
	TCCR1B = (1<<WGM12)|(1<<CS12)|(1<<CS10);
	TIMSK |= _BV(OCIE1A);
*/	
	DDRA = _BV(3)|_BV(4)|_BV(5)|_BV(1);
	//PORTA = _BV(3)|_BV(4)|_BV(5);
	sei();
	for(;;) 
	{
		PORTA |= _BV(1);
		my_delay();
		if (PINA == 0)
		{
			PORTA |= _BV(3);
			PORTA |= _BV(4);
		}
		else
		{
			PORTA &= ~_BV(3);
			PORTA &= ~_BV(4);
		}
		PORTA &= ~_BV(1);
		my_delay();
	}
	
	return 0;
}


